package com.ecommerce.dal.entity;
// Generated May 3, 2013 3:35:49 PM by Hibernate Tools 3.6.0

import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * CustomerItem generated by hbm2java
 */
@Entity
@Table(name = "customer_item")
public class CustomerItem implements java.io.Serializable {

	private CustomerItemId id;
	private Customer customer;
	private Item item;
	private Double discount;
	private long verification;
	private Date selectionDate;

	public CustomerItem() {
	}

	public CustomerItem(CustomerItemId id, Customer customer, Item item,
			long verification, Date selectionDate) {
		this.id = id;
		this.customer = customer;
		this.item = item;
		this.verification = verification;
		this.selectionDate = selectionDate;
	}

	public CustomerItem(CustomerItemId id, Customer customer, Item item,
			Double discount, long verification, Date selectionDate) {
		this.id = id;
		this.customer = customer;
		this.item = item;
		this.discount = discount;
		this.verification = verification;
		this.selectionDate = selectionDate;
	}

	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "customerId", column = @Column(name = "CUSTOMER_ID", nullable = false)),
			@AttributeOverride(name = "itemId", column = @Column(name = "ITEM_ID", nullable = false)) })
	public CustomerItemId getId() {
		return this.id;
	}

	public void setId(CustomerItemId id) {
		this.id = id;
	}

	/**
	 * Changed to EAGER fetching!
	 * @return
	 */
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "CUSTOMER_ID", nullable = false, insertable = false, updatable = false)
	public Customer getCustomer() {
		return this.customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	/**
	 * Changed to EAGER fetching!
	 * @return
	 */
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ITEM_ID", nullable = false, insertable = false, updatable = false)
	public Item getItem() {
		return this.item;
	}

	public void setItem(Item item) {
		this.item = item;
	}

	@Column(name = "DISCOUNT", precision = 22, scale = 0)
	public Double getDiscount() {
		return this.discount;
	}

	public void setDiscount(Double discount) {
		this.discount = discount;
	}

	@Column(name = "VERIFICATION", nullable = false)
	public long getVerification() {
		return this.verification;
	}

	public void setVerification(long verification) {
		this.verification = verification;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "SELECTION_DATE", nullable = false, length = 10)
	public Date getSelectionDate() {
		return this.selectionDate;
	}

	public void setSelectionDate(Date selectionDate) {
		this.selectionDate = selectionDate;
	}

}
